package com.zzc.legou.search.clients;


import com.zzc.legou.item.entity.Category;
import com.zzc.service.item.api.CategoryApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;


import java.util.List;


/**
 * 远程调用item服务
 */
@FeignClient(name = "item-service", fallback = CategoryClient.CategoryClientFallback.class)
public interface CategoryClient extends CategoryApi {

    @Component
    @RequestMapping("/category-fallback")
    class CategoryClientFallback implements CategoryClient {
        private static final Logger LOGGER = LoggerFactory.getLogger(CategoryClientFallback.class);

        @Override
        public List<Category> list(Category category) {
            LOGGER.error("调用分类接口失败");
            return null;
        }

        @Override
        public List<String> queryNameByIds(List<Long> ids) {
            LOGGER.error("根据名字查询id失败");
            return null;
        }

        @Override
        public Category edis(Long id) {
            LOGGER.error("根据id查询分类");
            return null;
        }
    }
}
